/*
 * An XML document type.
 * Localname: exception-handler
 * Namespace: urn:jbpm.org:jpdl-3.2
 * Java type: x2.orgJpdl3.jbpm.ExceptionHandlerDocument
 *
 * Automatically generated - do not modify.
 */
package x2.orgJpdl3.jbpm.impl;
/**
 * A document containing one exception-handler(@urn:jbpm.org:jpdl-3.2) element.
 *
 * This is a complex type.
 */
public class ExceptionHandlerDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements x2.orgJpdl3.jbpm.ExceptionHandlerDocument
{
    private static final long serialVersionUID = 1L;
    
    public ExceptionHandlerDocumentImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName EXCEPTIONHANDLER$0 = 
        new javax.xml.namespace.QName("urn:jbpm.org:jpdl-3.2", "exception-handler");
    
    
    /**
     * Gets the "exception-handler" element
     */
    public x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler getExceptionHandler()
    {
        synchronized (monitor())
        {
            check_orphaned();
            x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler target = null;
            target = (x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler)get_store().find_element_user(EXCEPTIONHANDLER$0, 0);
            if (target == null)
            {
                return null;
            }
            return target;
        }
    }
    
    /**
     * Sets the "exception-handler" element
     */
    public void setExceptionHandler(x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler exceptionHandler)
    {
        synchronized (monitor())
        {
            check_orphaned();
            x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler target = null;
            target = (x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler)get_store().find_element_user(EXCEPTIONHANDLER$0, 0);
            if (target == null)
            {
                target = (x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler)get_store().add_element_user(EXCEPTIONHANDLER$0);
            }
            target.set(exceptionHandler);
        }
    }
    
    /**
     * Appends and returns a new empty "exception-handler" element
     */
    public x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler addNewExceptionHandler()
    {
        synchronized (monitor())
        {
            check_orphaned();
            x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler target = null;
            target = (x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler)get_store().add_element_user(EXCEPTIONHANDLER$0);
            return target;
        }
    }
    /**
     * An XML exception-handler(@urn:jbpm.org:jpdl-3.2).
     *
     * This is a complex type.
     */
    public static class ExceptionHandlerImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements x2.orgJpdl3.jbpm.ExceptionHandlerDocument.ExceptionHandler
    {
        private static final long serialVersionUID = 1L;
        
        public ExceptionHandlerImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType);
        }
        
        private static final javax.xml.namespace.QName ACTION$0 = 
            new javax.xml.namespace.QName("urn:jbpm.org:jpdl-3.2", "action");
        private static final javax.xml.namespace.QName SCRIPT$2 = 
            new javax.xml.namespace.QName("urn:jbpm.org:jpdl-3.2", "script");
        private static final javax.xml.namespace.QName EXCEPTIONCLASS$4 = 
            new javax.xml.namespace.QName("", "exception-class");
        
        
        /**
         * Gets a List of "action" elements
         */
        public java.util.List<x2.orgJpdl3.jbpm.ActionDocument.Action> getActionList()
        {
            final class ActionList extends java.util.AbstractList<x2.orgJpdl3.jbpm.ActionDocument.Action>
            {
                public x2.orgJpdl3.jbpm.ActionDocument.Action get(int i)
                    { return ExceptionHandlerImpl.this.getActionArray(i); }
                
                public x2.orgJpdl3.jbpm.ActionDocument.Action set(int i, x2.orgJpdl3.jbpm.ActionDocument.Action o)
                {
                    x2.orgJpdl3.jbpm.ActionDocument.Action old = ExceptionHandlerImpl.this.getActionArray(i);
                    ExceptionHandlerImpl.this.setActionArray(i, o);
                    return old;
                }
                
                public void add(int i, x2.orgJpdl3.jbpm.ActionDocument.Action o)
                    { ExceptionHandlerImpl.this.insertNewAction(i).set(o); }
                
                public x2.orgJpdl3.jbpm.ActionDocument.Action remove(int i)
                {
                    x2.orgJpdl3.jbpm.ActionDocument.Action old = ExceptionHandlerImpl.this.getActionArray(i);
                    ExceptionHandlerImpl.this.removeAction(i);
                    return old;
                }
                
                public int size()
                    { return ExceptionHandlerImpl.this.sizeOfActionArray(); }
                
            }
            
            synchronized (monitor())
            {
                check_orphaned();
                return new ActionList();
            }
        }
        
        /**
         * Gets array of all "action" elements
         * @deprecated
         */
        public x2.orgJpdl3.jbpm.ActionDocument.Action[] getActionArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                java.util.List<x2.orgJpdl3.jbpm.ActionDocument.Action> targetList = new java.util.ArrayList<x2.orgJpdl3.jbpm.ActionDocument.Action>();
                get_store().find_all_element_users(ACTION$0, targetList);
                x2.orgJpdl3.jbpm.ActionDocument.Action[] result = new x2.orgJpdl3.jbpm.ActionDocument.Action[targetList.size()];
                targetList.toArray(result);
                return result;
            }
        }
        
        /**
         * Gets ith "action" element
         */
        public x2.orgJpdl3.jbpm.ActionDocument.Action getActionArray(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ActionDocument.Action target = null;
                target = (x2.orgJpdl3.jbpm.ActionDocument.Action)get_store().find_element_user(ACTION$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                return target;
            }
        }
        
        /**
         * Returns number of "action" element
         */
        public int sizeOfActionArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().count_elements(ACTION$0);
            }
        }
        
        /**
         * Sets array of all "action" element
         */
        public void setActionArray(x2.orgJpdl3.jbpm.ActionDocument.Action[] actionArray)
        {
            synchronized (monitor())
            {
                check_orphaned();
                arraySetterHelper(actionArray, ACTION$0);
            }
        }
        
        /**
         * Sets ith "action" element
         */
        public void setActionArray(int i, x2.orgJpdl3.jbpm.ActionDocument.Action action)
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ActionDocument.Action target = null;
                target = (x2.orgJpdl3.jbpm.ActionDocument.Action)get_store().find_element_user(ACTION$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                target.set(action);
            }
        }
        
        /**
         * Inserts and returns a new empty value (as xml) as the ith "action" element
         */
        public x2.orgJpdl3.jbpm.ActionDocument.Action insertNewAction(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ActionDocument.Action target = null;
                target = (x2.orgJpdl3.jbpm.ActionDocument.Action)get_store().insert_element_user(ACTION$0, i);
                return target;
            }
        }
        
        /**
         * Appends and returns a new empty value (as xml) as the last "action" element
         */
        public x2.orgJpdl3.jbpm.ActionDocument.Action addNewAction()
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ActionDocument.Action target = null;
                target = (x2.orgJpdl3.jbpm.ActionDocument.Action)get_store().add_element_user(ACTION$0);
                return target;
            }
        }
        
        /**
         * Removes the ith "action" element
         */
        public void removeAction(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_element(ACTION$0, i);
            }
        }
        
        /**
         * Gets a List of "script" elements
         */
        public java.util.List<x2.orgJpdl3.jbpm.ScriptDocument.Script> getScriptList()
        {
            final class ScriptList extends java.util.AbstractList<x2.orgJpdl3.jbpm.ScriptDocument.Script>
            {
                public x2.orgJpdl3.jbpm.ScriptDocument.Script get(int i)
                    { return ExceptionHandlerImpl.this.getScriptArray(i); }
                
                public x2.orgJpdl3.jbpm.ScriptDocument.Script set(int i, x2.orgJpdl3.jbpm.ScriptDocument.Script o)
                {
                    x2.orgJpdl3.jbpm.ScriptDocument.Script old = ExceptionHandlerImpl.this.getScriptArray(i);
                    ExceptionHandlerImpl.this.setScriptArray(i, o);
                    return old;
                }
                
                public void add(int i, x2.orgJpdl3.jbpm.ScriptDocument.Script o)
                    { ExceptionHandlerImpl.this.insertNewScript(i).set(o); }
                
                public x2.orgJpdl3.jbpm.ScriptDocument.Script remove(int i)
                {
                    x2.orgJpdl3.jbpm.ScriptDocument.Script old = ExceptionHandlerImpl.this.getScriptArray(i);
                    ExceptionHandlerImpl.this.removeScript(i);
                    return old;
                }
                
                public int size()
                    { return ExceptionHandlerImpl.this.sizeOfScriptArray(); }
                
            }
            
            synchronized (monitor())
            {
                check_orphaned();
                return new ScriptList();
            }
        }
        
        /**
         * Gets array of all "script" elements
         * @deprecated
         */
        public x2.orgJpdl3.jbpm.ScriptDocument.Script[] getScriptArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                java.util.List<x2.orgJpdl3.jbpm.ScriptDocument.Script> targetList = new java.util.ArrayList<x2.orgJpdl3.jbpm.ScriptDocument.Script>();
                get_store().find_all_element_users(SCRIPT$2, targetList);
                x2.orgJpdl3.jbpm.ScriptDocument.Script[] result = new x2.orgJpdl3.jbpm.ScriptDocument.Script[targetList.size()];
                targetList.toArray(result);
                return result;
            }
        }
        
        /**
         * Gets ith "script" element
         */
        public x2.orgJpdl3.jbpm.ScriptDocument.Script getScriptArray(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ScriptDocument.Script target = null;
                target = (x2.orgJpdl3.jbpm.ScriptDocument.Script)get_store().find_element_user(SCRIPT$2, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                return target;
            }
        }
        
        /**
         * Returns number of "script" element
         */
        public int sizeOfScriptArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().count_elements(SCRIPT$2);
            }
        }
        
        /**
         * Sets array of all "script" element
         */
        public void setScriptArray(x2.orgJpdl3.jbpm.ScriptDocument.Script[] scriptArray)
        {
            synchronized (monitor())
            {
                check_orphaned();
                arraySetterHelper(scriptArray, SCRIPT$2);
            }
        }
        
        /**
         * Sets ith "script" element
         */
        public void setScriptArray(int i, x2.orgJpdl3.jbpm.ScriptDocument.Script script)
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ScriptDocument.Script target = null;
                target = (x2.orgJpdl3.jbpm.ScriptDocument.Script)get_store().find_element_user(SCRIPT$2, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                target.set(script);
            }
        }
        
        /**
         * Inserts and returns a new empty value (as xml) as the ith "script" element
         */
        public x2.orgJpdl3.jbpm.ScriptDocument.Script insertNewScript(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ScriptDocument.Script target = null;
                target = (x2.orgJpdl3.jbpm.ScriptDocument.Script)get_store().insert_element_user(SCRIPT$2, i);
                return target;
            }
        }
        
        /**
         * Appends and returns a new empty value (as xml) as the last "script" element
         */
        public x2.orgJpdl3.jbpm.ScriptDocument.Script addNewScript()
        {
            synchronized (monitor())
            {
                check_orphaned();
                x2.orgJpdl3.jbpm.ScriptDocument.Script target = null;
                target = (x2.orgJpdl3.jbpm.ScriptDocument.Script)get_store().add_element_user(SCRIPT$2);
                return target;
            }
        }
        
        /**
         * Removes the ith "script" element
         */
        public void removeScript(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_element(SCRIPT$2, i);
            }
        }
        
        /**
         * Gets the "exception-class" attribute
         */
        public java.lang.String getExceptionClass()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(EXCEPTIONCLASS$4);
                if (target == null)
                {
                    return null;
                }
                return target.getStringValue();
            }
        }
        
        /**
         * Gets (as xml) the "exception-class" attribute
         */
        public org.apache.xmlbeans.XmlString xgetExceptionClass()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.XmlString target = null;
                target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(EXCEPTIONCLASS$4);
                return target;
            }
        }
        
        /**
         * True if has "exception-class" attribute
         */
        public boolean isSetExceptionClass()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().find_attribute_user(EXCEPTIONCLASS$4) != null;
            }
        }
        
        /**
         * Sets the "exception-class" attribute
         */
        public void setExceptionClass(java.lang.String exceptionClass)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(EXCEPTIONCLASS$4);
                if (target == null)
                {
                    target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(EXCEPTIONCLASS$4);
                }
                target.setStringValue(exceptionClass);
            }
        }
        
        /**
         * Sets (as xml) the "exception-class" attribute
         */
        public void xsetExceptionClass(org.apache.xmlbeans.XmlString exceptionClass)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.XmlString target = null;
                target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(EXCEPTIONCLASS$4);
                if (target == null)
                {
                    target = (org.apache.xmlbeans.XmlString)get_store().add_attribute_user(EXCEPTIONCLASS$4);
                }
                target.set(exceptionClass);
            }
        }
        
        /**
         * Unsets the "exception-class" attribute
         */
        public void unsetExceptionClass()
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_attribute(EXCEPTIONCLASS$4);
            }
        }
    }
}
